<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        /* 商品头部 */
        #app .header {
            display: flex;
            padding: 0 20px;
            margin-top: 10px;
            justify-content: space-between;
        }

        #app .header span {
            font-weight: bold;
        }

        /* 商品列表 */
        #app .content {
            margin-top: 20px;
        }

        #app .content .list {
            display: flex;
            justify-content: space-around;
            padding: 15px;
        }

        #app .content .list img {
            width: 80px;
            height: 80px;
        }

        #app .content .list .com_message {
            margin-left: 10px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

        }

        #app .content .list .com_message .price {
            color: red;
        }

        #app .content .list .com_message .original_price {
            text-decoration: line-through;
            font-size: 12px;
        }

        #app .content .list .com_message .name {
            font-size: 18px;
        }

        #app .content .list .com_quantity {
            margin-left: 80px;
            display: flex;
            align-items: flex-end;
        }

        #app .content .list .com_quantity button {
            width: 20px;
            height: 20px;
            border-radius: 50%;
        }

        /* 提示信息 */
        #app .content .empty {
            width: 100%;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 头部 -->
        <div class="header">
            <span>已选商品</span> <button @click="clear">清空</button>
        </div>
        <!-- 列表 -->
        <div class="content" v-if="list.length!=0">
            <div class="list" v-for="(item,index) in list">
                <div class="com_img">
                    <img :src="item.pic" alt="">
                </div>
                <div class="com_message">
                    <h2 class="name">{{item.name}}</h2>
                    <p><span class="price">￥{{item.price}}</span><span class="original_price">￥{{item.yj}}</span></p>
                </div>
                <div class="com_quantity">
                    <button @click="resuse(item, index)">-</button>&nbsp; <span>{{item.quantity}}</span> &nbsp;<button
                        @click="add(item,index)">+</button>
                </div>
            </div>
            <!-- <div class="empty" v-show="list.length==0">购物车空空如也，去逛逛把</div> -->


        </div>
        <div class="empty" v-else>购物车空空如也，去逛逛把</div>
    </div>

    <script src="vue-2.5.21.js"></script>
    <script src="index-购物车.js"></script>
</body>

</html>